procedure erat(max:longint); {PROST - array of boolean}
var i,j,k:longint;
begin
fillchar(prost,sizeof(prost),true);
k:=trunc(sqrt(max));
for i:=2 to k) do begin
  if prost[i] then begin
    j:=i*i;
    while j<=max do begin
      prost[j]:=false;
      inc(j,i);
    end;
  end;
end;
end;